﻿Imports Persistencia
Imports UtilPadrao
Public Class frmPrincipal

#Region "Variáveis"

    Private datPermissoes As New DataTable

#End Region

#Region "Propriedades"

    Public Shared Property codigoUsuario As Integer
    Public Shared Property nomeUsuario As String
    Public Shared Property codGrupo As Integer
    Public Shared Property codigoModulo As Integer = 2

#End Region

#Region "Eventos"

    Private Sub frmPrincipal_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Me.Hide()

        PersistenciaPadrao.AcessoBD.codSGBD = PersistenciaPadrao.AcessoBD.eSGBD.SQL_SERVER
        PersistenciaPadrao.AcessoBD.sCaminhoAplicacao = Application.StartupPath

#If Not Debug Then

        If Me.verificarConexao(Application.StartupPath) Then
            PersistenciaPadrao.AcessoBD.sStringConexao = UtilPadrao.Iniciais.lerArquivoConexao(Application.StartupPath)
            If Me.loginUsuario Then
                Me.Show()
                MyBase.configuraPermissoes(Me.mnuPrincipal.Items, Me.datPermissoes, codigoUsuario, codGrupo, codigoModulo,0)
            Else
                Me.Close()
            End If
        Else
            Me.Close()
        End If
#Else
        If Me.verificarConexao(Application.StartupPath) Then
            codigoUsuario = 0
            codGrupo = 0
            nomeUsuario = ""
            PersistenciaPadrao.AcessoBD.sStringConexao = UtilPadrao.Iniciais.lerArquivoConexao(Application.StartupPath)
            MyBase.configuraPermissoes(Me.mnuPrincipal.Items, Me.datPermissoes, codigoUsuario, codGrupo, codigoModulo, 0)
            Me.Show()
        End If

#End If

        Dim fvi As FileVersionInfo
        fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(Application.ExecutablePath)
        Me.lblVersao.Text = "Versão: " & fvi.FileVersion

    End Sub

#End Region

#Region "Métodos"

    Public Function loginUsuario() As Boolean

        Dim bLogin As Boolean = False
        'Dim frmLogin As New frmLogin_

        'frmLogin.ShowDialog()

        'If frmLogin.loginRealizado Then

        '    frmPrincipal.codigoUsuario = frmLogin.codUsuario
        '    frmPrincipal.nomeUsuario = frmLogin.nomeUsuario
        '    frmPrincipal.codGrupo = frmLogin.codGrupo

        '    bLogin = True
        'Else
        '    bLogin = False
        'End If

        Return bLogin

    End Function

#End Region

#Region "Menus"

    Private Sub mnuSegSair_Click(sender As System.Object, e As System.EventArgs) Handles mnuSegSair.Click
        Me.Close()
    End Sub

    Private Sub mnuSegGrupoAcesso_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSegGrupoAcesso.Click
        Dim frm As New frmGrupoAcesso
        MyBase.abrirFormularioPadrao(frm, sender, Me.datPermissoes)
    End Sub

    Private Sub mnuSegUsuario_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSegUsuario.Click
        Dim frm As New frmUsuario
        MyBase.abrirFormularioPadrao(frm, sender, Me.datPermissoes)
    End Sub

    Private Sub mnuSegConfigurar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim frm As New frmConfigurarModulos
        MyBase.abrirFormularioPadrao(frm, sender, Me.datPermissoes)
    End Sub

    Private Sub mnuSegEmpresa_Click(sender As System.Object, e As System.EventArgs) Handles mnuSegEmpresa.Click
        Dim frm As New frmEmpresa
        MyBase.abrirFormularioPadrao(frm, sender, Me.datPermissoes)
    End Sub

#End Region




End Class

